package com.chen.demo.javase.algorithm.leetcode.editor.cn;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author hongwei.chen
 * @date 2021/06/04 14:21
 **/
public class LRUMap {

    private static final Integer size = 16;


    public static void main(String[] args) {
        LinkedHashMap<String, String> lruMap = new LinkedHashMap<String, String>(size, 0.75f, true) {
            @Override
            protected boolean removeEldestEntry(Map.Entry<String, String> eldest) {
                return size() > size;

            }
        };

        for (int i = 100; i >= 0; i--) {
            lruMap.put(i + "", i + "");
        }

        System.out.println(lruMap.toString());
    }
}
